<!-- 50 create by dng 2021/12/22  -->
<template>
  <div class="page-wrap">
      <a-space class="common-button-group">
      <a-button
      class="t9-form-wideget-btn-default"
        type="primary"
        :loading="searchBtnLoading"
        @click="handleSearch"
        >{{ $t("common_query") }}</a-button
      >
    </a-space>
    <t-query-form
      layout="inline"
      ref="queryForm"
      group="ReleaseHoldByGlass"
      :rules="rules"
     :model="queryForm"
    >
          <a-form-item
            :label="$t('T9_shopId')"
            name="shopId"
            prop="shopId"
          >
            <a-select
              v-model:value="queryForm.shopId"
              class="t9-form-wideget-input-default"
              :placeholder="$t('common_pleaseSelect')"
              allow-clear
            >
              <a-select-option v-for="item in shopIdArr"
            :key="item.shopId" :value="item.shopId">
            {{item.shopId}}
            </a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item
            :label="$t('T9_productType')"
            name="productType"
            prop="productType"
          >
            <a-select
              v-model:value="queryForm.productType"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in options.productTypeList"
                :key="item.value"
                :value="item.value"
              >
                {{ item.value }}
              </a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item :label="$t('T9_productId')" name="productId" prop="productId">
            <a-select
              v-model:value="queryForm.productId"
              class="t9-form-wideget-input-default"
              allow-clear
              show-search
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in options.productIdList"
                :key="item.value"
                :value="item.value"
              >
                {{ item.value }}
              </a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item :label="$t('T9_holdReleasedDepartment')" name="holdReleasedDepartment" prop="holdReleasedDepartment">
           <a-select
              v-model:value="queryForm.holdReleasedDepartment"
              class="t9-form-wideget-input-default"
              allow-clear
              show-search
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in options.productIdList"
                :key="item.value"
                :value="item.value"
              >
                {{ item.value }}
              </a-select-option>
           </a-select>
          </a-form-item>
          <a-form-item :label="$t('T9_cstId')" name="cstId" prop="cstId">
            <a-input class="t9-form-wideget-input-default" v-model:value="queryForm.cstId" allow-clear :placeholder="$t('common_pleaseEnter1')" />
          </a-form-item>
    </t-query-form>
      <div style="display: flex; justify-content: space-between;  margin-bottom: 20px; width: 100%; height:100%">
         <div style="width: 30%">
        <a-row type="flex" justify="space-between" align="middle" class="global-oper-row mt-1">
        <a-col :span="15" class="global-oper-row-title">{{ $t('T9_cstList') }}</a-col>
        <a-col :span="8" class="global-oper-row-extra">
          <a-button class="t9-form-wideget-btn-default" type="primary" @click="getCstListExport">{{ $t('T9_toExcel') }}</a-button>
        </a-col>
      </a-row>
      <div class="page-wrap-table" style="height: 90%">
        <t-table align="center"
          :data="list.cstList"
          max-height="100%"
          :loading="searchBtnLoading"
          @radio-change="handleCstListChange"
        >
          <t-column  type="radio" width="50"></t-column>
          <t-column min-width="100" field="cstId" :title="$t('T9_cstId')" />
          <t-column min-width="100" field="productId" :title="$t('T9_productId')" />
          <t-column min-width="100" field="productVer" :title="$t('T9_productVer')" />
          <t-column min-width="100" field="operation" :title="$t('T9_operation')" />
          <t-column min-width="100" field="owner" :title="$t('T9_owner')" />
          <t-column min-width="100" field="priority" :title="$t('T9_priority')" />
          <t-column min-width="100" field="glassQty" :title="$t('T9_glassQty')" />
          <t-column min-width="100" field="dueDate" :title="$t('T9_dueDate')" />
          <t-column min-width="100" field="holdState" :title="$t('T9_holdState')" />
        </t-table>
      </div>
      </div>
       <div style="width: 30%">
        <a-row type="flex" justify="space-between" align="middle" class="global-oper-row mt-1">
        <a-col :span="15" class="global-oper-row-title">{{ $t('T9_holdCodeList') }}</a-col>
        <a-col :span="8" class="global-oper-row-extra">
          <a-button class="t9-form-wideget-btn-default" type="primary" @click="getHoldCodeListExport">{{ $t('T9_toExcel') }}</a-button>
        </a-col>
      </a-row>
      <div class="page-wrap-table" style="height: 90%">
        <t-table align="center"
          :data="list.holdCodeList"
          max-height="100%"
          :loading="searchBtnLoading"
          @radio-change="handleHoldCodeListChange"
        >
          <t-column  type="radio" width="50"></t-column>
          <t-column min-width="100" field="glassQty" :title="$t('T9_glassQty')" />
          <t-column min-width="100" field="holdCode" :title="$t('T9_holdCode')" />
          <t-column min-width="130" field="holdDescription" :title="$t('T9_holdDescription')" />
          <t-column min-width="150" field="confirmDepartment" :title="$t('T9_releasedDepartment')" />
          <t-column min-width="130" field="eventComment" :title="$t('T9_eventComment')" />
          <t-column min-width="100" field="eventTime" :title="$t('T9_eventTime')" />
          <t-column min-width="100" field="eventUser" :title="$t('T9_eventUser')" />
        </t-table>
      </div>
      </div>
       <div style="width: 39%">
        <a-row type="flex" justify="space-between" align="middle" class="global-oper-row mt-1">
        <a-col :span="4" class="global-oper-row-title">{{ $t('T9_glassList') }}</a-col>
        <a-col :span="5">
          <a-checkbox  v-model:checked="selectSameHold">{{$t('T9_selectSameHold')}}</a-checkbox>
        </a-col>
         <a-col :span="4">
            <a-checkbox  v-model:checked="selectByAbs">{{$t('T9_selectByAbs')}}</a-checkbox>
        </a-col>
        <a-col :span="10" class="global-oper-row-extra">
          <a-button class="t9-form-wideget-btn-default" type="primary" @click="getGlassListExport">{{ $t('T9_toExcel') }}</a-button>
        </a-col>
      </a-row>
      <div class="page-wrap-table" style="height: 90%">
        <t-table align="center"
        ref="table"
          :data="list.glassList"
          max-height="100%"
          :loading="searchBtnLoading"
          :edit-config="{trigger: 'click', mode: 'row'}"
          @edit-actived="editActivedEvent"
          @checkbox-change="handleCheckChange"
        >
          <t-column  type="checkbox" width="50"></t-column>
          <t-column min-width="100" field="slot" :title="$t('T9_slot')" />
          <t-column min-width="100" field="glassId" :title="$t('T9_glassId')" />
          <t-column min-width="150" v-if="dataForm.action === 'Rework'" field="reasonCodeCategory" :title="$t('T9_reasonCodeCategory')" :edit-render="{}" >
              <template #edit="{ row }">
              <a-select v-model="row.reasonCodeCategory" clearable transfer @change="roleChangeEvent({row})">
                <a-option v-for="item in reasonCodeArr" :key="item.reasonCode" :value="item.reasonCode" :label="item.reasonCode" ></a-option>
              </a-select>
            </template>
          </t-column>
          <t-column min-width="150" v-else field="reasonCodeCategory" :title="$t('T9_reasonCodeCategory')" />
          <t-column min-width="100" v-if="dataForm.action === 'Rework'"  field="holdCode" :title="$t('T9_holdCode')" :edit-render="{}">
            <template #edit="{ row }">
              <a-select v-model="row.holdCode" clearable transfer @change="roleChangeEvent">
                <a-option v-for="item in reasonCodeArr" :key="item.desc" :value="item.desc" :label="item.desc" ></a-option>
              </a-select>
            </template>
          </t-column>
          <t-column min-width="100" v-else field="holdCode" :title="$t('T9_holdCode')" />
          <t-column min-width="100" v-if="dataForm.action === 'Rework'" field="causeEQPId" :title="$t('T9_causeEqpId')" :edit-render="{}">
            <template #edit="{ row }">
              <a-select v-model="row.causeEqpId" clearable transfer @change="roleChangeEvent">
                <a-option v-for="item in eqpIdArr" :key="item.eqpId" :value="item.eqpId" :label="item.eqpId" ></a-option>
              </a-select>
            </template>
          </t-column>
          <t-column min-width="100" v-else field="causeEQPId" :title="$t('T9_causeEqpId')" />
          <t-column min-width="100" field="glassGrade" :title="$t('T9_glassGrade')" />
          <t-column min-width="150" field="holdPermissonName" :title="$t('T9_holdPermissonName')" />
          <t-column min-width="100" field="desc" :title="$t('T9_desc')" />
          <t-column min-width="100" field="reasonCode" :title="$t('T9_reasonCode')" />
          <t-column min-width="100" field="holdFlag" :title="$t('T9_holdFlag')" />
          <t-column min-width="100" field="abnormalCode" :title="$t('T9_abnormalCode')" />
          <t-column min-width="100" field="panelGrades" :title="$t('T9_panelGrades')" />
        </t-table>
      </div>
      </div>
      </div>
      <div class='data-form page-wrap-bottom mt-1'>
        <a-form
          ref="dataForm"
          layout="inline"
          :colon="false"
          :model="dataForm"
          :rules="rules2"
        >
           <a-form-item
            :label="$t('T9_action')"
            name="action"
            prop="action"
          >
            <a-select
              v-model:value="dataForm.action"
              class="t9-form-wideget-input-default"
              allow-clear
              @change="handlerChange"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option value="Release Hold">Release Hold</a-select-option>
              <a-select-option value="Rework">Rework</a-select-option>
              <a-select-option value="Sampling">Sampling</a-select-option>
            </a-select>
          </a-form-item>
             <a-form-item
            :label="$t('T9_sampleType')"
            name="sampleType"
            prop="sampleType"
          >
            <a-select
              v-model:value="dataForm.sampleType"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
              :disabled="sampleDisabled"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in options.sampleTypeList"
                :key="item.value"
                :value="item.value"
              >
                {{ item.value }}
              </a-select-option>
            </a-select>
          </a-form-item>
             <a-form-item
            :label="$t('T9_route')"
            name="route"
            prop="route"
          >
            <a-select
              v-model:value="dataForm.route"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
              @change="handleRoute"
              :disabled="disabled"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in routeArr"
                :key="item.route"
                :value="item.route"
                :route-ver="item.routeVer"
              >
                {{ item.route }}
              </a-select-option>
            </a-select>
          </a-form-item>
             <a-form-item
            :label="$t('T9_opeartion')"
            name="opeartion"
            prop="opeartion"
          >
            <a-select
              v-model:value="dataForm.opeartion"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
               :disabled="disabled"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in operationArr"
                :key="item.processOperationName"
                :value="item.processOperationName"
              >
                {{ item.processOperationName }}
              </a-select-option>
            </a-select>
          </a-form-item>
             <a-form-item
            :label="$t('T9_reworkReasonCode')"
            name="reworkReasonCode"
            prop="reworkReasonCode"
          >
            <a-select
              v-model:value="dataForm.reworkReasonCode"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
               :disabled="reworkDisable"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in reasonCodeArr"
                :key="item.reasonCodeCategory"
                :value="item.reasonCodeCategory"
              >
                {{ item.reasonCodeCategory }}
              </a-select-option>
            </a-select>
            <a-select
              v-model:value="dataForm.holdCode"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
               :disabled="reworkDisable"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in holdCodeArr"
                :key="item.reasonCode"
                :value="item.reasonCode"
              >
                {{ item.reasonCode }}
              </a-select-option>
            </a-select>
          </a-form-item>
             <a-form-item
            :label="$t('T9_causeEqpId')"
            name="causeEqpId"
            prop="causeEqpId"
          >
            <a-select
              v-model:value="dataForm.causeEqpId"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
               :disabled="reworkDisable"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in eqpIdArr"
                :key="item.causeEqpId"
                :value="item.causeEqpId"
              >
                {{ item.causeEqpId }}
              </a-select-option>
            </a-select>
          </a-form-item>
             <a-form-item
            :label="$t('T9_department')"
            name="department"
            prop="department"
          >
            <a-select
              v-model:value="dataForm.department"
              class="t9-form-wideget-input-default"
              show-search
              allow-clear
               :disabled="disabled"
              :placeholder="$t('common_pleaseSelect')"
            >
              <a-select-option
                v-for="item in departmentArr"
                :key="item.enumValue"
                :value="item.enumValue"
              >
                {{ item.enumValue }}
              </a-select-option>
            </a-select>
          </a-form-item>
           <a-form-item :label="$t('T9_comment')" class="comment-box" name="eventComment" prop="eventComment" style="width:100%">
            <a-row type="flex" justify="space-between" align="middle">
              <a-col :span="21">
                <a-textarea allow-clear v-model:value="dataForm.eventComment" :rows="1" :title="dataForm.eventComment" />
              </a-col>
              <a-col :span="2">
                <a-button class="t9-form-wideget-btn-default" type="primary" :loading="confirmBtnLoading" @click="handleConfirm">{{ $t('T9_confirm') }}</a-button>
              </a-col>
            </a-row>
          </a-form-item>
        </a-form>
      </div>
  </div>
</template>

<script>
  import { defineComponent } from 'vue'
  import * as api from '@/api/common'
  import { getRouteSamplingList, getRouteReworkList } from '@/api/releaseHoldByGlass'
  import { downloadBlobFile } from '@/utils/download'
  import initOptionsMixin from '@/mixins/initOptionsMixin'
   import confirmUserMixin from '@/mixins/confirmUser.mixin'

  export default defineComponent({
    name: 'ReleaseHoldByGlass',
    mixins: [initOptionsMixin, confirmUserMixin],
    data() {
      return {
        confirmBtnLoading: false,
        selectSameHold: false,
        selectByAbs: false,
        searchBtnLoading: false,
        shopIdArr: [],
        departmentArr: [],
        routeArr: [],
        operationArr: [],
        reasonCodeArr: [],
        holdCodeArr: [],
        eqpIdArr: [],
        cleanProductList: [],
        productList: [],
        holdCodeRow: {},
        cstRow: {},
        glassQueryId: '',
        glassVersion: '',
        lotId: '',
        route: '',
        operation: '',
        cstId: '',
        productVer: '',
        departmentQueryId: '',
        checkedIndex: 0,
        export: false,
        disabled: true,
        sampleDisabled: true,
        reworkDisable: true,
        list: {
          cstList: [],
          holdCodeList: [],
          glassList: []
        },
        queryForm: {
          shopId: 'ARRAY',
          productType: undefined,
          productId: undefined,
          holdReleasedDepartment: undefined,
          cstId: undefined
        },
        options: {
        },
        dataForm: {
          action: 'Release Hold',
          sampleType: undefined,
          route: undefined,
          operation: undefined,
          reworkReasonCode: undefined,
          holdCode: undefined,
          causeEqpId: undefined,
          department: undefined,
          eventComment: undefined,
          eventUser: ''
        },
        rules: {
          shopId: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }],
          productType: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }]
        },
        rules2: {
          action: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }],
          sampleType: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }],
          route: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }],
          operation: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }],
          reworkReasonCode: [{ required: true, message: this.$t('valid_required2'), trigger: 'change' }],
          eventComment: [{ required: true, message: this.$t('valid_required2'), trigger: 'blur' }]
        }
      }
    },
    computed: {},
    created() {
      this.getShopId()
      this.initOptions([{ name: 'productType' }])
    },
    watch: {
      selectSameHold: {
        handler(val) {
          if (!val) return
          if (!this.list.holdCodeList.length) return
           const arr = this.list.glassList.filter(item => item.glassHoldState === 'OnHold' && item.reasonCode === this.list.holdCodeList[0].reasonCode)
           this.$refs.table.setCheckboxRow([...arr], true)
        }
      },
      selectByAbs: {
        handler(val) {
          if (!val) return
           const params = {
            dtoName: 'NeedSamplingGlassByABSDTO',
            shopId: this.queryForm.shopId,
            glassId: '',
            menuName: 'releaseHoldByGlass',
            usage: 'getByABS'
          }
          api.getList(params).then(res => {
            console.log(res, 'res')
          })
        }
      },
       'queryForm.productType': {
        handler(productType) {
          this.queryForm.productId = undefined
          this.initOptions([{
             name: 'productId',
             params: {
               shopId: this.queryForm.shopId, productType, version: '80001', queryId: 'GetEnumDefValueList'
             }
          }])
        }
      },
      'dataForm.action': {
        handler(action) {
          this.handleHoldCodeListChange(this.holdCodeRow)
          if (action === 'Rework') {
            this.departmentQueryId = 'GetDepartmentList'
            this.disabled = false
            this.reworkDisable = false
            this.sampleDisabled = true
            this.getRouteReworkList()
            this.getReworkReasonCodeCategory()
            this.getReworkReasonCode()
            this.getReworkCauseEqpId()
            this.dataForm.sampleType = undefined
          } else if (action === 'Sampling') {
            this.departmentQueryId = 'GetForceSamplingFlowList'
            this.reworkDisable = true
            this.disabled = false
            this.sampleDisabled = false
            this.dataForm.reworkReasonCode = undefined
            this.dataForm.holdCode = undefined
             this.dataForm.causeEqpId = undefined
            this.getRouteSamplingList()
           this.initOptions([{ name: 'sampleType', params: { enumName: 'SampleCheckType', enumValue: '' } }])
          } else {
            this.departmentQueryId = ''
            this.disabled = true
            this.reworkDisable = true
            this.sampleDisabled = true
            this.dataForm.sampleType = undefined
            this.dataForm.reworkReasonCode = undefined
            this.dataForm.holdCode = undefined
            this.dataForm.causeEqpId = undefined
            return
          }
           this.getDepartment()
        }
      },
      'dataForm.reworkReasonCode': {
        handler() {
          this.getReworkReasonCode()
        }
      }
    },
    methods: {
        getReworkReasonCodeCategory() {
         const params = {
            dtoName: 'ReworkReworkReasonCodeCategoryDTO',
            queryId: 'GetReasonCodeList',
            version: '80001',
            menuName: 'rework',
            usage: 'getResonCodeCategroy',
            reasonCodeType: 'REWORK',
            shopId: this.queryForm.shopId
         }
         api.getList(params).then(res => {
           this.reasonCodeArr = res
         })
       },
         getReworkReasonCode() {
          const params = {
            dtoName: 'ReworkReworkCodeDTO',
            queryId: 'GetReasonCodeList',
            version: '80006',
            menuName: 'rework',
            usage: 'getReasonCode',
            reasonCodeType: 'REWORK',
            reasonCodeCategory: this.dataForm.reworkReasonCode,
            shopId: this.queryForm.shopId
         }
         api.getList(params).then(res => {
           this.holdCodeArr = res
         })
       },
         getReworkCauseEqpId() {
          const params = {
            dtoName: 'ReworkCauseEqpIdDTO',
            queryId: 'GetMachineList',
            version: '81004',
            menuName: 'rework',
            usage: 'getCauseEqpId',
            detailMachineType: 'MAIN',
            shopId: this.queryForm.shopId
         }
         api.getList(params).then(res => {
           this.eqpIdArr = res
         })
       },
      getRouteReworkList() {
         getRouteReworkList({ shopId: this.queryForm.shopId, route: this.route, operation: this.operation }).then(res => {
              this.routeArr = res
            })
      },
     getRouteSamplingList() {
         getRouteSamplingList({ shopId: this.queryForm.shopId, lotId: this.lotId }).then(res => {
              this.routeArr = res
            })
     },
      updatePnameList() {
        console.log('111')
      },
      editActivedEvent() {
        this.updatePnameList()
      },
      roleChangeEvent(row) {
        console.log(row, 'row')
      },
      handleRoute(val, o) {
        const params = {
          route: val,
          version: '80031',
          routeVer: o.routeVer,
          shopId: this.queryForm.shopId
        }
        api.getOperation(params).then(res => {
          console.log(res, 'oo')
          this.operationArr = res
        this.dataForm.operation = '000'
        })
      },
      getDepartment() {
        const params = {
          queryId: this.departmentQueryId
        }
        api.getDepartment(params).then(res => {
          this.departmentArr = res
        })
      },
       getShopId() {
        const params = {
        }
        api.getShopId(params).then((res) => {
          this.shopIdArr = res
        })
      },
      handleSearch() {
        this.$refs.queryForm
          .validate()
          .then(() => {
            this.getCstList()
          })
      },
      // 获取cstList
      getCstList() {
         if (this.searchBtnLoading) return
          this.searchBtnLoading = true
          if (!this.queryForm.cstId) {
            this.version = '80017'
          } else {
            this.version = '80016'
          }
          const params = {
            dtoName: 'CSTListDTO',
            queryId: 'GetHoldLotList',
            version: this.version,
            menuName: 'releaseHoldByGlass',
            usage: 'queryCstList',
            export: this.export,
            ...this.queryForm
          }
          api.getList(params).then(res => {
            if (this.export) {
              downloadBlobFile(res, 'cstList')
              this.export = false
            } else {
               this.list.cstList = res
            }
            this.searchBtnLoading = false
          })
          .catch(error => {
            this.searchBtnLoading = false
            console.log(error)
          })
      },
      // cstList导出
      getCstListExport() {
         if (!this.list.cstList.length) return
        this.export = true
        this.getCstList()
      },
      // cstList勾选
      handleCstListChange({ row }) {
         this.dataForm.action = 'Release Hold'
        console.log(row)
        this.lotId = row.lotId
        this.route = row.route
        this.operation = row.operation
        this.cstId = row.cstId
        this.cstRow = row
        this.productVer = row.productVer
        const params = {
          dtoName: 'HoldCodeListDTO',
          queryId: 'GetMultiHoldCodeList',
          version: '80003',
          menuName: 'releaseHoldByGlass',
          usage: 'queryHoldCodeList',
          lotId: this.lotId,
          shopId: this.queryForm.shopId,
          export: this.export
        }
        api.getList(params).then(res => {
          this.list.holdCodeList = res
        })
        // if (this.dataForm.action === 'Rework') {
        //   this.getRouteReworkList()
        // } else if (this.dataForm.action === 'Sampling') {
        //   this.getRouteSamplingList()
        // } else {
        //   console.log('releas')
        // }
      },
      // holdCodeList 导出
      getHoldCodeListExport() {
         if (!this.list.holdCodeList.length) return
           if (this.dataForm.action === 'Release Hold') {
          this.glassQueryId = 'GetMultiHoldCodeList'
          this.glassVersion = '80004'
        } else {
          this.glassQueryId = 'GetHoldProductList'
          this.glassVersion = '80002'
        }
         this.export = true
         const params = {
          dtoName: 'HoldCodeListDTO',
          queryId: this.glassQueryId,
          version: this.glassVersion,
          menuName: 'releaseHoldByGlass',
          usage: 'queryHoldCodeList',
          lotId: this.lotId,
          shopId: this.queryForm.shopId,
          export: this.export
        }
        api.getList(params).then(res => {
          downloadBlobFile(res, 'holdCodeList')
        })
      },
      // holdCodeList 勾选
      handleHoldCodeListChange(row) {
        if (this.dataForm.action === 'Release Hold') {
          this.glassQueryId = 'GetMultiHoldCodeList'
          this.glassVersion = '80004'
        } else {
          this.glassQueryId = 'GetHoldProductList'
          this.glassVersion = '80002'
        }
        this.holdCodeRow = row
        this.checkedIndex = row.rowIndex
          const params = {
          dtoName: 'ReleaseHoldByGlassListDTO',
          queryId: this.glassQueryId,
          version: this.glassVersion,
          menuName: 'releaseHoldByGlass',
          usage: 'queryGlassList',
          export: this.export,
          shopId: this.queryForm.shopId,
          lotId: this.lotId,
          action: this.dataForm.action,
          cstId: this.cstId,
          checkedIndex: 0
        }
        api.getList(params).then(res => {
          this.list.glassList = res
        })
      },
      // glassList 导出
      getGlassListExport() {
         if (!this.list.glassList.length) return
        this.export = true
         const params = {
          dtoName: 'ReleaseHoldByGlassListDTO',
          queryId: 'GetProductList',
          version: '80002',
          menuName: 'releaseHoldByGlass',
          usage: 'queryGlassList',
          export: this.export,
          shopId: this.queryForm.shopId,
          lotId: this.lotId,
          action: this.dataForm.action,
          checkedIndex: 0
        }
        api.getList(params).then(res => {
          downloadBlobFile(res, 'glassList')
        })
      },
      // glassList 勾选
      handleCheckChange({ row }) {
        console.log(row)
        this.productList.push(row)
        this.cleanProductList.push(row.glassId)
      },
      handleConfirm() {
        // this.$refs.dataForm.validate().then(() => {

        // }).catch((error) => {
        //   console.log('error', error)
        // })
       this.confirmUser(this.handleOk)
      },
       handleOk() {
        this.confirmBtnLoading = true
        this.dataForm.eventUser = this.$store.state.user.uid
        const params = {
           menuName: 'releaseHoldByGlass',
          usage: 'confirm',
          action: this.dataForm.action,
          cleanProductList: this.cleanProductList,
          cstId: this.cstId,
          route: this.route,
          productVer: this.productVer,
          productId: this.cstRow.productId,
          doLotReleaseHoldByGlassBody: {
            actionFlag: this.dataForm.action,
            alterFlowName: this.dataForm.route,
            alterOperationName: this.dataForm.operation,
            eventComment: this.dataForm.eventComment,
            eventUser: this.$store.state.user.uid,
            language: 'English',
            lotId: this.lotId,
            operation: this.operation,
            reworkReasonCode: this.dataForm.reworkReasonCode,
            route: this.route,
            rwFlowName: this.dataForm.holdCode,
            sampleCheckType: this.dataForm.sampleType,
            productlist: this.productList.length ? this.productList.map(t => {
              const {
                eqpId = t.causeEQPId,
                glassId = t.glassId,
                productReasonCode = t.holdCode
                } = t
              return {
                eqpId,
                glassId,
                productReasonCode,
                needRework: '',
                reasonCode: this.dataForm.holdCode,
                requestDepartment: this.dataForm.department,
                productReasonCodeType: 'REWORK'
              }
            }) : []
          },
          // glassReleaseHoldBody: {
          //   actionFlag: '',
          //   alterFlowName: '',
          //   alterOperationName: '',
          //   eventComment: '',
          //   eventUser: '',
          //   language: '',
          //   lotId: '',
          //   operation: '',
          //   reasonList: [],
          //   route: ''
          // },
            processFlowName: this.dataForm.route,
            shopId: this.queryForm.shopId,
            userId: this.$store.state.user.uid
        }
        api.confirm(params).then(() => {
          this.confirmBtnLoading = false
        }).catch(error => {
          this.confirmBtnLoading = false
          console.error(error)
        })
      }
    }
  })
</script>
<style lang='less' scoped>
.t9-form-wideget-input-default {
  width: 150px;
}
</style>
